package com.rajaev.dtu.tractor.domain.repository.mysql;

import com.rajaev.dtu.tractor.domain.entity.UserInfo;
import com.rajaev.dtu.tractor.domain.vo.UserVo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface UserDao {

    UserInfo selectUserByLoginName(@Param("loginName") String loginName);

    @Select("select * from t_user where id = #{userId} and delete_flag = '0' ")
    @ResultMap("UserPoMap")
    UserInfo selectUserById(@Param("userId") Integer userId);

    @Select("select customer_id from t_user_customer where user_id = #{userId} ")
    List<Integer> selectUserCustomerIds(Integer userId);


    Integer insert(UserInfo userInfo);

    Integer update(UserInfo userPo);

    List<UserVo> selectUsers();

    @Update("update t_user set delete_flag = '1' where id = #{userId} ")
    void deleteUser(Integer userId);

    void updateUserSystemDisplayName(@Param("userId") Integer userId,@Param("systemName") String systemName);


    @Update("update t_user set password = #{newPassword} where id = #{userId} ")
    void updateUserPassword(@Param("userId") Integer userId,@Param("newPassword") String newPassword);
}
